// 招待单列表
var indColumns = [{
        id: 'userName',
        title: '姓名',
        type: 'string',
        width: 75,
        columnClass: 'text-center',
    }, {
        id: 'sex',
        title: '性别',
        type: 'string',
        width: 50,
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            if (record.sex == 1) {
                return "男";
            }
            return "女";
        }
    }, {
        id: 'belongCompanyName',
        title: '常驻公司',
        type: 'string',
        columnClass: 'text-left'
    },
    {
        id: 'departmentName',
        title: '部门名称',
        type: 'string',
        columnClass: 'text-left'
        // ,
        // resolution: function (value, record, column, grid, dataNo, columnNo) {
        //     if (record.departmentUser) {
        //         return record.departmentUser.departmentName
        //     }
        //     return null;
        // }
    }, {
        id: 'readyToWork',
        title: '拟入职时间',
        type: 'string',
        width: 100,
        columnClass: 'text-center',
    }, {
        id: 'createUserName',
        title: '申请人',
        type: 'string',
        width: 75,
        columnClass: 'text-center',
    }, {
        id: 'createTime',
        title: '申请时间',
        type: 'string',
        width: 100,
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var date = new Date(record.createTime);
            var content = $.fn.dlshouwen.grid.tools.dateFormat(date, "yyyy-MM-dd hh:mm");
            return content;
        }
    }, {
        id: 'sfzddn',
        title: '电脑',
        type: 'string',
        width: 50,
        columnClass: 'text-center',
    }, {
        id: 'seatCode',
        title: '座位号',
        type: 'string',
        width: 80,
        columnClass: 'text-center',
    },
    {
        id: 'userId',
        title: '工号',
        type: 'string',
        width: 60,
        columnClass: 'text-center',
    },
    {
        id: 'phoneNumber',
        title: '手机',
        type: 'string',
        width: 60,
        columnClass: 'text-center',
    },
    {
        id: 'positonName',
        title: '岗位',
        type: 'string',
        width: 60,
        columnClass: 'text-center',
    },
    {
        id: 'onPost',
        title: '状态',
        type: 'string',
        width: 60,
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            // 1 在職 2 待入職 3 未報到
            if (record.onPost == 1) {
                return "在职";
            } else if (record.onPost == 2) {
                return "待入职";
            } else if (record.onPost == 3) {
                return "未入职";
            } else if (record.onPost == 4) {
                return "离职";
            } else if (record.onPost == 5) {
                return "取消入职";
            }
        }
    },
    {
        id: 'operation',
        title: '操作',
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '';
            content += '<a class="btn btn-xs btn-success" href="#/printInd/' + record.id + '"><i class="icon-print"></i>  打印</a>';
            
            if (record.isDis == "yes") {
                content += ' '
                content += '<a class="btn btn-xs btn-warning" href="#/infoInd/' + record.id + '"><i class="icon-eye-open"></i>  查看</a>';
                if (record.onPost != 1 && record.onPost != 5) {
                    content += ' '
                    content += '<a class="btn btn-xs btn-info" href="#/alterInd/' + record.id + '"><i class="icon-edit"></i>  修改</a>';
                }
            }

            return content;
        }
    }
];

function lfimg(start) {
    var json = {
        "title": "工位图", //相册标题
        "id": 1, //相册id
        "start": start, //初始显示的图片序号，默认0
        "data": [ //相册包含的图片，数组格式
            {
                "alt": "南京18栋1楼工位图",
                "pid": 0, //图片id
                "src": "img/18-1.jpg", //原图地址
                "thumb": "" //缩略图地址
            },
            {
                "alt": "南京18栋2楼工位图",
                "pid": 1, //图片id
                "src": "img/18-2.jpg", //原图地址
                "thumb": "" //缩略图地址
            },
            {
                "alt": "南京18栋3楼工位图",
                "pid": 2, //图片id
                "src": "img/18-3.jpg", //原图地址
                "thumb": "" //缩略图地址
            },
            {
                "alt": "南京18栋4楼工位图",
                "pid": 3, //图片id
                "src": "img/18-4.jpg", //原图地址
                "thumb": "" //缩略图地址
            },
            {
                "alt": "南京9栋1楼工位图",
                "pid": 4, //图片id
                "src": "img/9-1.jpg", //原图地址
                "thumb": "" //缩略图地址
            },
            {
                "alt": "上海工位图",
                "pid": 5, //图片id
                "src": "img/6-11.jpg", //原图地址
                "thumb": "" //缩略图地址
            }
        ]
    };
    layer.photos({
        photos: json, //格式见API文档手册页
        anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
    });
};

function selBimg() {
    var city = $("#city").val();
    var build = $("#build").val();
    var fool = $("#fool").val();
    //console.log(city, build, fool);
    if (city == "NJ") {
        if (build == "B18") {
            if (fool == "F01") {
                $("#lfimg").show();
                $("#imgbox").attr("src", "img/18-1.jpg");
            }
            if (fool == "F02") {
                $("#lfimg").show();
                $("#imgbox").attr("src", "img/18-2.jpg");
            }
            if (fool == "F03") {
                $("#lfimg").show();
                $("#imgbox").attr("src", "img/18-3.jpg");
            }
            if (fool == "F04") {
                $("#lfimg").show();
                $("#imgbox").attr("src", "img/18-4.jpg");
            }
        }
        if (build == "B09") {
            if (fool == "F01") {
                $("#lfimg").show();
                $("#imgbox").attr("src", "img/9-1.jpg");
            }
        }
    } else if(city == "SH"){
        if(build == "B06"){
            if(fool == "F11"){
                $("#lfimg").show();
                $("#imgbox").attr("src", "img/6-11.png");
            }
        }
    } else {
        $("#lfimg").hide();
    }
}


// 查看预览
function showinfo() {
    $('#userinfo').modal('show');
}

function hidesh() {
    $('#userinfo').modal('hide');
}

//
var $$scope;
$("#jiTime1").datetimepicker({
    format: 'YYYY-MM-DD',
    locale: moment.locale('zh-cn')
}).on('dp.change', function (e) {
    var result = new moment(e.date).format('YYYY-MM-DD');
    if (result && !angular.isUndefined(result)) {
        $$scope.rzlcStepEntity.baseUser.readyToWork = result;
        $$scope.$apply();
    }
});
$("#jiTime").datetimepicker({
    format: 'YYYY-MM-DD',
    locale: moment.locale('zh-cn')
}).on('dp.change', function (e) {
    var result = new moment(e.date).format('YYYY-MM-DD');
    if (result && !angular.isUndefined(result)) {
        $$scope.rzlcStepEntity.readyToWork = result;
        $$scope.$apply();
    }
});
$("#birTime").datetimepicker({
    format: 'YYYY-MM-DD',
    locale: moment.locale('zh-cn')
}).on('dp.change', function (e) {
    var result = new moment(e.date).format('YYYY-MM-DD');
    if (result && !angular.isUndefined(result)) {
        $$scope.rzlcStepEntity.baseUser.birthday = result;
        $$scope.$apply();
    }
});

$("#firTime").datetimepicker({
    format: 'YYYY-MM-DD',
    locale: moment.locale('zh-cn')
}).on('dp.change', function (e) {
    var result = new moment(e.date).format('YYYY-MM-DD');
    if (result && !angular.isUndefined(result)) {
        $$scope.rzlcStepEntity.baseUser.firstWorkTime = result;
        $$scope.$apply();
    }
});